from slum.model.base import Base
from slum.model.artist import Artist

import simplejson

from sqlalchemy import Column, ForeignKey, Index, Integer, String, DateTime, Date, Time, Float, Enum, Boolean
from sqlalchemy.sql import func

class Song(Base):
    ''' XXX 
    '''
    __tablename__ = 'song'
    id = Column(Integer, primary_key=True)

    name   = Column(String)
    length = Column(String)
    key    = Column(String)
    time   = Column(Time)

    created = Column(DateTime, default=func.current_timestamp())

    artist_id  = Column(
        Integer,
        ForeignKey(Artist.id),
        nullable=True
    )

    # single table inheritance stuff that identifies  
    discriminator = Column('name', String(50))
    __mapper_args__ = {'polymorphic_on': discriminator}

    def index(self, id=False, date=False):
        ''' XXXX  XXX '''
        dict = {'Stop':4, 'color':11}
        return simplejson.dumps(dict)

    index.exposed = True
